package org.nf.trading.controller.app.product;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nf.trading.controller.BaseController;
import org.nf.trading.dto.CommentReplySecondaryDTO;
import org.nf.trading.entity.Comment;
import org.nf.trading.entity.CommentReply;
import org.nf.trading.service.app.product.ProductCommentService;
import org.nf.trading.vo.ResultVO;
import org.springframework.web.bind.annotation.*;

@RestController
@RequiredArgsConstructor
@CrossOrigin
@Slf4j
@RequestMapping("/api/product/comment")
public class ProductCommentController extends BaseController {
    private final ProductCommentService productCommentService;

    /**
     * 添加评论
     * @param comment
     * @return
     */
    @PostMapping
    public ResultVO insertComment(@RequestBody Comment comment){
        Comment comment1 = productCommentService.insertComment(comment);
        return success(comment1);
    }
    /**
     *  添加商品评论回复
     * @param commentReply
     * @return
     */
    @PostMapping("/commentReply")
    public ResultVO addProductCommentReply(@RequestBody CommentReply commentReply){
        CommentReplySecondaryDTO secondaryDTO = productCommentService.addCommentReply(commentReply);
        return success(secondaryDTO);
    }
}
